package com.shph.validation.rule.impl;

import com.shph.validation.exception.ValidFailException;
import com.shph.validation.rule.IRule;

/**
 * 断言校验实现类
 * 校验Boolean值，如果为 true 返回 true
 */
public class AssertTrueRule implements IRule<Boolean> {
    @Override
    public boolean test(Boolean value, String refValue) {
        boolean ast = value == null ? false : value;
        if (!ast) {
            throw new ValidFailException("该值必须为 true！");
        }
        return true;
    }
}
